home *** CD-ROM | disk | FTP | other *** search
- /*
- * LANPERF - PC Tech Journal LAN Performance Test
- * Copyright (c) 1988, Ziff Communications Company
- *
- * To build LANPERF.EXE:
- * cl /c LANPERF.C (Compiled with Microsoft C 5.0)
- * masm LPTEST.ASM; (Assembled with Microsoft MASM 4.0)
- * link LANPERF+LPTEST;
- */
-
- #include <stdio.h>
- #include <stdlib.h>
-
- /* this value needs to match with the one in LPTEST.ASM */
- #define MAXBLK 4096 /* maximum blksize value */
-
-
- /* information used by rtest() and wtest() ASM routines */
-
- int master; /* did we start the test? */
- unsigned int blksize; /* block I/O size in bytes */
- unsigned int filesize; /* size of file in blksize blocks */
- char ioshare; /* sharing mode for tests */
- char iobuf[2*MAXBLK]; /* I/O buffer */
- unsigned int duration; /* length of test (seconds) */
- long ops; /* total operations performed */
- char fname[20]; /* name of test file created */
-
- char *modename[] =
- {
- "Compatibility", "Deny read/write", "Deny write",
- "Deny read", "Deny none", "??"
- };
-
- main(int argc, char **argv)
- {
- unsigned int atou(const char *str);
- int i, err;
- int do_read, do_write;
-
- printf("LANPERF Version 1.0\n");
- printf("PC Tech Journal LAN Performance Test\n");
- printf("Copyright (c) 1988, Ziff Communications Company\n\n");
-
- if ( argc < 2 )
- {
- printf("Options:\n");
- printf(" t# - test length (seconds) (10-65535)\n");
- printf(" b# - block size (in bytes) (1-%d)\n", MAXBLK);
- printf(" f# - file size (in blocks) (1-65535)\n");
- printf(" w - do sequential write test\n");
- printf(" r - do sequential read test\n");
- printf(" dM - file sharing mode\n");
- printf(" ^ modes to deny (r w rw n c)\n");
- printf(" x - use defaults: t60 b512 f64 r w dc\n");
- exit(1);
- }
-
- /* set default values */
- blksize = 512;
- filesize = 64;
- duration = 60;
- ioshare = 0; /* compatibility mode */
- do_read = 0;
- do_write = 0;
-
- /* decode arguments */
- for ( argv++, argc--; argc > 0; argv++, argc-- )
- {
- switch ( tolower(**argv) )
- {
- case 't' :
- duration = atou(*argv + 1);
- if ( duration < 10 )
- {
- printf("Illegal test time: %s\n", *argv);
- exit(1);
- }
- break;
- case 'b':
- blksize = atou(*argv + 1);
- if ( blksize == 0 || blksize > MAXBLK )
- {
- printf("Illegal block size: %s\n", *argv);
- exit(1);
- }
- break;
- case 'f':
- filesize = atou(*argv + 1);
- if ( filesize == 0 )
- {
- printf("Illegal file size: %s\n", *argv);
- exit(1);
- }
- break;
- case 'd':
- switch ( tolower(*(*argv + 1)) )
- {
- case 'r':
- if ( tolower(*(*argv + 2)) == 'w' )
- ioshare = 0x10; /* deny r/w */
- else
- ioshare = 0x30; /* deny read */
- break;
- case 'w':
- ioshare = 0x20; /* deny write */
- break;
- case 'n':
- ioshare = 0x40; /* deny none */
- break;
- case 'c':
- ioshare = 0x00; /* compatibility */
- break;
- default:
- printf("Illegal sharing mode: %s\n", *argv);
- exit(1);
- }
- break;
- case 'w':
- do_write = 1;
- break;
- case 'r':
- do_read = 1;
- break;
- case 'x':
- break;
- default:
- printf("unknown option: %s\n", *argv);
- exit(1);
- }
- }
-
- /* If read or write not specified, do both */
- if ( !do_read && !do_write )
- {
- do_read = 1;
- do_write = 1;
- }
-
- printf("Test time : %u seconds\n", duration);
- printf("Block size : %u bytes\n", blksize);
- printf("File size : %u blocks (%lu bytes)\n",
- filesize, (long)filesize * blksize);
- printf("Sharing : %s\n\n", modename[ioshare >> 4]);
- printf("===> PRESS A KEY ON ANY STATION TO START <===\n\n");
- printf(" Total Mean Response Throughput\n");
- printf("Test Operations Time (ms) (KB/s)\n");
- printf("---- ---------- ------------- ----------\n");
-
- /* Fill buffer with random data pattern */
- srand(19);
- for ( i = 0; i < sizeof(iobuf); i++ )
- iobuf[i] = rand();
-
- strcpy(fname, "LANPERF.GO");
- unlink(fname); /* in case it's already there */
- if ( (err = lpstart()) )
- fatal(err);
-
- if ( do_write )
- {
- printf("WRITE :");
- if ( (err = wtest()) )
- fatal(err);
- printf("%8ld %8.3f %8.2f\n",
- ops,
- 1000.0 * (float)duration / (float)ops,
- ((float)ops * (float)blksize) / (duration * 1024.0));
- }
-
- if ( do_read )
- {
- printf("READ :");
- if ( (err = rtest()) )
- fatal(err);
- printf("%8ld %8.3f %8.2f\n",
- ops,
- 1000.0 * (float)duration / (float)ops,
- ((float)ops * (float)blksize) / (duration * 1024.0));
- }
-
- if ( master )
- unlink("LANPERF.GO");
-
- exit(0);
- }
-
-
- fatal(int err)
- {
- static char *doscode[] =
- {
- "No error",
- "Invalid function",
- "File not found",
- "Path not found",
- "Too many open files",
- "Access denied",
- "Invalid handle",
- "Memory is trashed",
- "Insufficient memory",
- "Invalid memory block",
- "Bad environment",
- "Invalid format",
- "Invalid access code",
- "Invalid data",
- "??",
- "Invalid drive",
- "Can't remove current directory",
- "Not same device",
- "No more matching files",
- };
-
- if ( err < 0 )
- printf("\nERROR: possible disk full?");
- else
- {
- printf("\nDOS error %u, ", err);
- if ( err >= sizeof(doscode)/sizeof(doscode[0]) )
- printf("??\n");
- else
- printf("%s\n",doscode[err]);
- }
- unlink("LANPERF.GO");
- exit(1);
- }
-
- #include <ctype.h>
- #include <limits.h>
-
- unsigned int
- atou(const char *str)
- {
- unsigned long tmp = 0;
-
- /* convert a string to an unsigned integer */
- while ( *str )
- {
- if ( isdigit(*str) )
- tmp = tmp * 10 + (*str++ - '0');
- else
- return(0); /* garbage */
- }
- if ( tmp > UINT_MAX )
- return(0); /* number too big */
- return((unsigned int)tmp);
- }